package com.example.a79273.shandianban;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.example.a79273.shandianban.client.MyChormeClient;
import com.example.a79273.shandianban.client.MyWebViewClient;
import com.example.a79273.shandianban.config.NetconfigYouHuo;

public class WebActivity extends BaseActivity {

    private WebView mWebView;
    private String pic_id;
    private String mWebViewPath;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        initView();
        initData();
        setData();
    }

    private void setData() {
        mWebView.loadUrl(mWebViewPath);
        mWebView.setWebViewClient(new MyWebViewClient());
        mWebView.setWebChromeClient(new MyChormeClient());
        // 获取WebView的基本设置
        WebSettings settings = mWebView.getSettings();
        // 设置和js交互是否可用
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(true);
    }

    private void initData() {
        pic_id = getIntent().getStringExtra("pic_id");
        mWebViewPath = NetconfigYouHuo.TOP_PIC_PATH_WEB_PATH + pic_id;

    }

    private void initView() {
        mWebView = (WebView) findViewById(R.id.wv_web_webview);
    }
}
